import { useMemo } from 'react';
import { useSearchParams } from 'react-router-dom';

const useQuery = <T extends { [k: string]: string }>() => {
    const [searchParams] = useSearchParams();
    // Object.fromEntries() 方法把键值对列表转换为一个对象。
    return useMemo<T>(() => Object.fromEntries(searchParams) as T, [searchParams]);
};

export default useQuery;





